package cn.humaohua.study.yanmo_design_pattern.ch15.v3;

import java.util.List;

public abstract class Component {
    /**
     * 记录父组件对象
     */
    private Component parent = null;

    public Component getParent() {
        return parent;
    }

    public void setParent(Component parent) {
        this.parent = parent;
    }

    public List<Component> getChildren() {
        throw new UnsupportedOperationException("对象不支持这个功能");
    }

    /* 下面是原有定义 */

    public abstract void printStruct(String preStr);

    public void addChild(Component child) {
        throw new UnsupportedOperationException("对象不支持这个功能");
    }

    public void removeChild(Component child) {
        throw new UnsupportedOperationException("对象不支持这个功能");
    }

    public void getChildren(int index) {
        throw new UnsupportedOperationException("对象不支持这个功能");
    }
}
